import { useState, useEffect } from 'react';

export default function Counter() {
  const [count, setCount] = useState(0);
  function onTick() {
    setCount(c => c + 1);
  }
  useEffect(() => {
    const TIMEINTERVEL = setInterval(onTick, 1000);
    return () => clearInterval(TIMEINTERVEL);
  }, []);

  return <h1>{count}</h1>;
}
